// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.ai.states;

import fmod.fmod.FMODManager;
import java.util.HashMap;
import zombie.ai.State;
import zombie.audio.parameters.ParameterZombieState;
import zombie.characterTextures.BloodBodyPartType;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.characters.IsoZombie;
import zombie.characters.MoveDeltaModifiers;
import zombie.characters.skills.PerkFactory;
import zombie.core.Rand;
import zombie.core.math.PZMath;
import zombie.core.skinnedmodel.advancedanimation.AnimEvent;
import zombie.iso.IsoDirections;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoMovingObject;
import zombie.iso.IsoObject;
import zombie.iso.IsoWorld;
import zombie.iso.Vector2;
import zombie.iso.SpriteDetails.IsoFlagType;
import zombie.iso.objects.IsoThumpable;
import zombie.iso.objects.IsoWindow;
import zombie.iso.objects.IsoWindowFrame;
import zombie.util.Type;

public final class ClimbThroughWindowState extends State {
    private static final ClimbThroughWindowState _instance = new ClimbThroughWindowState();
    static final Integer PARAM_START_X = 0;
    static final Integer PARAM_START_Y = 1;
    static final Integer PARAM_Z = 2;
    static final Integer PARAM_OPPOSITE_X = 3;
    static final Integer PARAM_OPPOSITE_Y = 4;
    static final Integer PARAM_DIR = 5;
    static final Integer PARAM_ZOMBIE_ON_FLOOR = 6;
    static final Integer PARAM_PREV_STATE = 7;
    static final Integer PARAM_SCRATCH = 8;
    static final Integer PARAM_COUNTER = 9;
    static final Integer PARAM_SOLID_FLOOR = 10;
    static final Integer PARAM_SHEET_ROPE = 11;
    static final Integer PARAM_END_X = 12;
    static final Integer PARAM_END_Y = 13;

    public static ClimbThroughWindowState instance() {
        return _instance;
    }

    @Override
    public void enter(IsoGameCharacter owner) {
        owner.setIgnoreMovement(true);
        owner.setHideWeaponModel(true);
        HashMap hashMap = owner.getStateMachineParams(this);
        boolean _boolean = hashMap.get(PARAM_COUNTER) == Boolean.TRUE;
        owner.setVariable("ClimbWindowStarted", false);
        owner.setVariable("ClimbWindowEnd", false);
        owner.setVariable("ClimbWindowFinished", false);
        owner.clearVariable("ClimbWindowGetUpBack");
        owner.clearVariable("ClimbWindowGetUpFront");
        owner.setVariable("ClimbWindowOutcome", _boolean ? "obstacle" : "success");
        owner.clearVariable("ClimbWindowFlopped");
        IsoZombie isoZombie = Type.tryCastTo(owner, IsoZombie.class);
        if (!_boolean && isoZombie != null && isoZombie.shouldDoFenceLunge()) {
            this.setLungeXVars(isoZombie);
            owner.setVariable("ClimbWindowOutcome", "lunge");
        }

        if (hashMap.get(PARAM_SOLID_FLOOR) == Boolean.FALSE) {
            owner.setVariable("ClimbWindowOutcome", "fall");
        }

        if (!(owner instanceof IsoZombie) && hashMap.get(PARAM_SHEET_ROPE) == Boolean.TRUE) {
            owner.setVariable("ClimbWindowOutcome", "rope");
        }

        if (owner instanceof IsoPlayer && ((IsoPlayer)owner).isLocalPlayer()) {
            ((IsoPlayer)owner).dirtyRecalcGridStackTime = 20.0F;
        }
    }

    @Override
    public void execute(IsoGameCharacter owner) {
        HashMap hashMap = owner.getStateMachineParams(this);
        if (!this.isWindowClosing(owner)) {
            IsoDirections isoDirections = (IsoDirections)hashMap.get(PARAM_DIR);
            owner.setDir(isoDirections);
            String string = owner.getVariableString("ClimbWindowOutcome");
            if (owner instanceof IsoZombie) {
                boolean _boolean = hashMap.get(PARAM_ZOMBIE_ON_FLOOR) == Boolean.TRUE;
                if (!owner.isFallOnFront() && _boolean) {
                    int int0 = (Integer)hashMap.get(PARAM_OPPOSITE_X);
                    int int1 = (Integer)hashMap.get(PARAM_OPPOSITE_Y);
                    int int2 = (Integer)hashMap.get(PARAM_Z);
                    IsoGridSquare isoGridSquare0 = IsoWorld.instance.CurrentCell.getGridSquare(int0, int1, int2);
                    if (isoGridSquare0 != null && isoGridSquare0.getBrokenGlass() != null) {
                        owner.addBlood(BloodBodyPartType.Head, true, true, true);
                        owner.addBlood(BloodBodyPartType.Head, true, true, true);
                        owner.addBlood(BloodBodyPartType.Head, true, true, true);
                        owner.addBlood(BloodBodyPartType.Head, true, true, true);
                        owner.addBlood(BloodBodyPartType.Head, true, true, true);
                        owner.addBlood(BloodBodyPartType.Neck, true, true, true);
                        owner.addBlood(BloodBodyPartType.Neck, true, true, true);
                        owner.addBlood(BloodBodyPartType.Neck, true, true, true);
                        owner.addBlood(BloodBodyPartType.Neck, true, true, true);
                        owner.addBlood(BloodBodyPartType.Torso_Upper, true, true, true);
                        owner.addBlood(BloodBodyPartType.Torso_Upper, true, true, true);
                        owner.addBlood(BloodBodyPartType.Torso_Upper, true, true, true);
                    }
                }

                owner.setOnFloor(_boolean);
                ((IsoZombie)owner).setKnockedDown(_boolean);
                owner.setFallOnFront(_boolean);
            }

            float float0 = (float)((Integer)hashMap.get(PARAM_START_X)).intValue() + 0.5F;
            float float1 = (float)((Integer)hashMap.get(PARAM_START_Y)).intValue() + 0.5F;
            if (!owner.getVariableBoolean("ClimbWindowStarted")) {
                if (owner.x != float0 && (isoDirections == IsoDirections.N || isoDirections == IsoDirections.S)) {
                    this.slideX(owner, float0);
                }

                if (owner.y != float1 && (isoDirections == IsoDirections.W || isoDirections == IsoDirections.E)) {
                    this.slideY(owner, float1);
                }
            }

            if (owner instanceof IsoPlayer && string.equalsIgnoreCase("obstacle")) {
                float float2 = (float)((Integer)hashMap.get(PARAM_END_X)).intValue() + 0.5F;
                float float3 = (float)((Integer)hashMap.get(PARAM_END_Y)).intValue() + 0.5F;
                if (owner.DistToSquared(float2, float3) < 0.5625F) {
                    owner.setVariable("ClimbWindowOutcome", "obstacleEnd");
                }
            }

            if (owner instanceof IsoPlayer
                && !owner.getVariableBoolean("ClimbWindowEnd")
                && !"fallfront".equals(string)
                && !"back".equals(string)
                && !"fallback".equals(string)) {
                int int3 = (Integer)hashMap.get(PARAM_OPPOSITE_X);
                int int4 = (Integer)hashMap.get(PARAM_OPPOSITE_Y);
                int int5 = (Integer)hashMap.get(PARAM_Z);
                IsoGridSquare isoGridSquare1 = IsoWorld.instance.CurrentCell.getGridSquare(int3, int4, int5);
                if (isoGridSquare1 != null) {
                    this.checkForFallingBack(isoGridSquare1, owner);
                    if (isoGridSquare1 != owner.getSquare() && isoGridSquare1.TreatAsSolidFloor()) {
                        this.checkForFallingFront(owner.getSquare(), owner);
                    }
                }
            }

            if (owner.getVariableBoolean("ClimbWindowStarted")
                && !"back".equals(string)
                && !"fallback".equals(string)
                && !"lunge".equals(string)
                && !"obstacle".equals(string)
                && !"obstacleEnd".equals(string)) {
                float float4 = (float)((Integer)hashMap.get(PARAM_START_X)).intValue();
                float float5 = (float)((Integer)hashMap.get(PARAM_START_Y)).intValue();
                switch (isoDirections) {
                    case N:
                        float5 -= 0.1F;
                        break;
                    case S:
                        float5++;
                        break;
                    case W:
                        float4 -= 0.1F;
                        break;
                    case E:
                        float4++;
                }

                if ((int)owner.x != (int)float4 && (isoDirections == IsoDirections.W || isoDirections == IsoDirections.E)) {
                    this.slideX(owner, float4);
                }

                if ((int)owner.y != (int)float5 && (isoDirections == IsoDirections.N || isoDirections == IsoDirections.S)) {
                    this.slideY(owner, float5);
                }
            }

            if (owner.getVariableBoolean("ClimbWindowStarted") && hashMap.get(PARAM_SCRATCH) == Boolean.TRUE) {
                hashMap.put(PARAM_SCRATCH, Boolean.FALSE);
                owner.getBodyDamage().setScratchedWindow();
            }
        }
    }

    private void checkForFallingBack(IsoGridSquare isoGridSquare, IsoGameCharacter isoGameCharacter) {
        for (int _int = 0; _int < isoGridSquare.getMovingObjects().size(); _int++) {
            IsoMovingObject isoMovingObject = (IsoMovingObject)isoGridSquare.getMovingObjects().get(_int);
            IsoZombie isoZombie = Type.tryCastTo(isoMovingObject, IsoZombie.class);
            if (isoZombie != null && !isoZombie.isOnFloor() && !isoZombie.isSitAgainstWall()) {
                if (!isoZombie.isVariable("AttackOutcome", "success") && Rand.Next(5 + isoGameCharacter.getPerkLevel(PerkFactory.Perks.Fitness)) != 0) {
                    isoZombie.playHurtSound();
                    isoGameCharacter.setVariable("ClimbWindowOutcome", "back");
                } else {
                    isoZombie.playHurtSound();
                    isoGameCharacter.setVariable("ClimbWindowOutcome", "fallback");
                }
            }
        }
    }

    private void checkForFallingFront(IsoGridSquare isoGridSquare, IsoGameCharacter isoGameCharacter) {
        for (int _int = 0; _int < isoGridSquare.getMovingObjects().size(); _int++) {
            IsoMovingObject isoMovingObject = (IsoMovingObject)isoGridSquare.getMovingObjects().get(_int);
            IsoZombie isoZombie = Type.tryCastTo(isoMovingObject, IsoZombie.class);
            if (isoZombie != null && !isoZombie.isOnFloor() && !isoZombie.isSitAgainstWall() && isoZombie.isVariable("AttackOutcome", "success")) {
                isoZombie.playHurtSound();
                isoGameCharacter.setVariable("ClimbWindowOutcome", "fallfront");
            }
        }
    }

    @Override
    public void exit(IsoGameCharacter owner) {
        owner.setIgnoreMovement(false);
        owner.setHideWeaponModel(false);
        HashMap hashMap = owner.getStateMachineParams(this);
        if (owner.isVariable("ClimbWindowOutcome", "fall")
            || owner.isVariable("ClimbWindowOutcome", "fallback")
            || owner.isVariable("ClimbWindowOutcome", "fallfront")) {
            owner.setHitReaction("");
        }

        owner.clearVariable("ClimbWindowFinished");
        owner.clearVariable("ClimbWindowOutcome");
        owner.clearVariable("ClimbWindowStarted");
        owner.clearVariable("ClimbWindowFlopped");
        if (owner instanceof IsoZombie) {
            owner.setOnFloor(false);
            ((IsoZombie)owner).setKnockedDown(false);
        }

        IsoZombie isoZombie = Type.tryCastTo(owner, IsoZombie.class);
        if (isoZombie != null) {
            isoZombie.AllowRepathDelay = 0.0F;
            if (hashMap.get(PARAM_PREV_STATE) == PathFindState.instance()) {
                if (owner.getPathFindBehavior2().getTargetChar() == null) {
                    owner.setVariable("bPathFind", true);
                    owner.setVariable("bMoving", false);
                } else if (isoZombie.isTargetLocationKnown()) {
                    owner.pathToCharacter(owner.getPathFindBehavior2().getTargetChar());
                } else if (isoZombie.LastTargetSeenX != -1) {
                    owner.pathToLocation(isoZombie.LastTargetSeenX, isoZombie.LastTargetSeenY, isoZombie.LastTargetSeenZ);
                }
            } else if (hashMap.get(PARAM_PREV_STATE) == WalkTowardState.instance() || hashMap.get(PARAM_PREV_STATE) == WalkTowardNetworkState.instance()) {
                owner.setVariable("bPathFind", false);
                owner.setVariable("bMoving", true);
            }
        }

        if (owner instanceof IsoZombie) {
            ((IsoZombie)owner).networkAI.isClimbing = false;
        }
    }

    public void slideX(IsoGameCharacter owner, float x) {
        float _float = 0.05F * zombie.GameTime.getInstance().getMultiplier() / 1.6F;
        _float = x > owner.x ? Math.min(_float, x - owner.x) : Math.max(-_float, x - owner.x);
        owner.x += _float;
        owner.nx = owner.x;
    }

    public void slideY(IsoGameCharacter owner, float y) {
        float _float = 0.05F * zombie.GameTime.getInstance().getMultiplier() / 1.6F;
        _float = y > owner.y ? Math.min(_float, y - owner.y) : Math.max(-_float, y - owner.y);
        owner.y += _float;
        owner.ny = owner.y;
    }

    @Override
    public void animEvent(IsoGameCharacter owner, AnimEvent event) {
        HashMap hashMap = owner.getStateMachineParams(this);
        IsoZombie isoZombie = Type.tryCastTo(owner, IsoZombie.class);
        if (event.m_EventName.equalsIgnoreCase("CheckAttack") && isoZombie != null && isoZombie.target instanceof IsoGameCharacter) {
            ((IsoGameCharacter)isoZombie.target).attackFromWindowsLunge(isoZombie);
        }

        if (event.m_EventName.equalsIgnoreCase("OnFloor") && isoZombie != null) {
            boolean _boolean = Boolean.parseBoolean(event.m_ParameterValue);
            hashMap.put(PARAM_ZOMBIE_ON_FLOOR, _boolean);
            if (_boolean) {
                this.setLungeXVars(isoZombie);
                IsoThumpable isoThumpable = Type.tryCastTo(this.getWindow(owner), IsoThumpable.class);
                if (isoThumpable != null && isoThumpable.getSquare() != null && isoZombie.target != null) {
                    isoThumpable.Health = isoThumpable.Health - Rand.Next(10, 20);
                    if (isoThumpable.Health <= 0) {
                        isoThumpable.destroy();
                    }
                }

                owner.setVariable("ClimbWindowFlopped", true);
            }
        }

        if (event.m_EventName.equalsIgnoreCase("PlayWindowSound")) {
            if (!zombie.SoundManager.instance.isListenerInRange(owner.getX(), owner.getY(), 10.0F)) {
                return;
            }

            long _long = owner.getEmitter().playSoundImpl(event.m_ParameterValue, null);
            owner.getEmitter().setParameterValue(_long, FMODManager.instance.getParameterDescription("TripObstacleType"), 9.0F);
        }

        if (event.m_EventName.equalsIgnoreCase("SetState")) {
            if (isoZombie == null) {
                return;
            }

            try {
                ParameterZombieState.State state = ParameterZombieState.State.valueOf(event.m_ParameterValue);
                isoZombie.parameterZombieState.setState(state);
            } catch (IllegalArgumentException illegalArgumentException) {
            }
        }
    }

    @Override
    public boolean isIgnoreCollide(IsoGameCharacter owner, int fromX, int fromY, int fromZ, int toX, int toY, int toZ) {
        HashMap hashMap = owner.getStateMachineParams(this);
        int int0 = (Integer)hashMap.get(PARAM_START_X);
        int int1 = (Integer)hashMap.get(PARAM_START_Y);
        int int2 = (Integer)hashMap.get(PARAM_END_X);
        int int3 = (Integer)hashMap.get(PARAM_END_Y);
        int int4 = (Integer)hashMap.get(PARAM_Z);
        if (int4 == fromZ && int4 == toZ) {
            int int5 = PZMath.min(int0, int2);
            int int6 = PZMath.min(int1, int3);
            int int7 = PZMath.max(int0, int2);
            int int8 = PZMath.max(int1, int3);
            int int9 = PZMath.min(fromX, toX);
            int int10 = PZMath.min(fromY, toY);
            int int11 = PZMath.max(fromX, toX);
            int int12 = PZMath.max(fromY, toY);
            return int5 <= int9 && int6 <= int10 && int7 >= int11 && int8 >= int12;
        } else {
            return false;
        }
    }

    public IsoObject getWindow(IsoGameCharacter owner) {
        if (!owner.isCurrentState(this)) {
            return null;
        } else {
            HashMap hashMap = owner.getStateMachineParams(this);
            int int0 = (Integer)hashMap.get(PARAM_START_X);
            int int1 = (Integer)hashMap.get(PARAM_START_Y);
            int int2 = (Integer)hashMap.get(PARAM_Z);
            IsoGridSquare isoGridSquare0 = IsoWorld.instance.CurrentCell.getGridSquare(int0, int1, int2);
            int int3 = (Integer)hashMap.get(PARAM_END_X);
            int int4 = (Integer)hashMap.get(PARAM_END_Y);
            IsoGridSquare isoGridSquare1 = IsoWorld.instance.CurrentCell.getGridSquare(int3, int4, int2);
            if (isoGridSquare0 != null && isoGridSquare1 != null) {
                Object object = isoGridSquare0.getWindowTo(isoGridSquare1);
                if (object == null) {
                    object = isoGridSquare0.getWindowThumpableTo(isoGridSquare1);
                }

                if (object == null) {
                    object = isoGridSquare0.getHoppableTo(isoGridSquare1);
                }

                return (IsoObject)object;
            } else {
                return null;
            }
        }
    }

    public boolean isWindowClosing(IsoGameCharacter owner) {
        HashMap hashMap = owner.getStateMachineParams(this);
        if (owner.getVariableBoolean("ClimbWindowStarted")) {
            return false;
        } else {
            int int0 = (Integer)hashMap.get(PARAM_START_X);
            int int1 = (Integer)hashMap.get(PARAM_START_Y);
            int int2 = (Integer)hashMap.get(PARAM_Z);
            IsoGridSquare isoGridSquare = IsoWorld.instance.CurrentCell.getGridSquare(int0, int1, int2);
            if (owner.getCurrentSquare() != isoGridSquare) {
                return false;
            } else {
                IsoWindow isoWindow = Type.tryCastTo(this.getWindow(owner), IsoWindow.class);
                if (isoWindow == null) {
                    return false;
                } else {
                    IsoGameCharacter isoGameCharacter = isoWindow.getFirstCharacterClosing();
                    if (isoGameCharacter != null && isoGameCharacter.isVariable("CloseWindowOutcome", "success")) {
                        if (owner.isZombie()) {
                            owner.setHitReaction("HeadLeft");
                        } else {
                            owner.setVariable("ClimbWindowFinished", true);
                        }

                        return true;
                    } else {
                        return false;
                    }
                }
            }
        }
    }

    @Override
    public void getDeltaModifiers(IsoGameCharacter owner, MoveDeltaModifiers modifiers) {
        boolean boolean0 = owner.getPath2() != null;
        boolean boolean1 = owner instanceof IsoPlayer;
        if (boolean0 && boolean1) {
            modifiers.turnDelta = Math.max(modifiers.turnDelta, 10.0F);
        }

        if (boolean1 && owner.getVariableBoolean("isTurning")) {
            modifiers.turnDelta = Math.max(modifiers.turnDelta, 5.0F);
        }
    }

    private boolean isFreeSquare(IsoGridSquare isoGridSquare) {
        return isoGridSquare != null && isoGridSquare.TreatAsSolidFloor() && !isoGridSquare.Is(IsoFlagType.solid) && !isoGridSquare.Is(IsoFlagType.solidtrans);
    }

    private boolean isObstacleSquare(IsoGridSquare isoGridSquare) {
        return isoGridSquare != null
            && isoGridSquare.TreatAsSolidFloor()
            && !isoGridSquare.Is(IsoFlagType.solid)
            && isoGridSquare.Is(IsoFlagType.solidtrans)
            && !isoGridSquare.Is(IsoFlagType.water);
    }

    private IsoGridSquare getFreeSquareAfterObstacles(IsoGridSquare isoGridSquare1, IsoDirections isoDirections) {
        while (true) {
            IsoGridSquare isoGridSquare0 = isoGridSquare1.getAdjacentSquare(isoDirections);
            if (isoGridSquare0 == null
                || isoGridSquare1.isSomethingTo(isoGridSquare0)
                || isoGridSquare1.getWindowFrameTo(isoGridSquare0) != null
                || isoGridSquare1.getWindowThumpableTo(isoGridSquare0) != null) {
                return null;
            }

            if (this.isFreeSquare(isoGridSquare0)) {
                return isoGridSquare0;
            }

            if (!this.isObstacleSquare(isoGridSquare0)) {
                return null;
            }

            isoGridSquare1 = isoGridSquare0;
        }
    }

    private void setLungeXVars(IsoZombie isoZombie) {
        IsoMovingObject isoMovingObject = isoZombie.getTarget();
        if (isoMovingObject != null) {
            isoZombie.setVariable("FenceLungeX", 0.0F);
            isoZombie.setVariable("FenceLungeY", 0.0F);
            float float0 = 0.0F;
            Vector2 vector2 = isoZombie.getForwardDirection();
            PZMath.SideOfLine sideOfLine = PZMath.testSideOfLine(
                isoZombie.x, isoZombie.y, isoZombie.x + vector2.x, isoZombie.y + vector2.y, isoMovingObject.x, isoMovingObject.y
            );
            float float1 = (float)Math.acos((double)isoZombie.getDotWithForwardDirection(isoMovingObject.x, isoMovingObject.y));
            float float2 = PZMath.clamp(PZMath.radToDeg(float1), 0.0F, 90.0F);
            switch (sideOfLine) {
                case Left:
                    float0 = -float2 / 90.0F;
                    break;
                case OnLine:
                    float0 = 0.0F;
                    break;
                case Right:
                    float0 = float2 / 90.0F;
            }

            isoZombie.setVariable("FenceLungeX", float0);
        }
    }

    public boolean isPastInnerEdgeOfSquare(IsoGameCharacter owner, int x, int y, IsoDirections moveDir) {
        if (moveDir == IsoDirections.N) {
            return owner.y < (float)(y + 1) - 0.3F;
        } else if (moveDir == IsoDirections.S) {
            return owner.y > (float)y + 0.3F;
        } else if (moveDir == IsoDirections.W) {
            return owner.x < (float)(x + 1) - 0.3F;
        } else if (moveDir == IsoDirections.E) {
            return owner.x > (float)x + 0.3F;
        } else {
            throw new IllegalArgumentException("unhandled direction");
        }
    }

    public boolean isPastOuterEdgeOfSquare(IsoGameCharacter owner, int x, int y, IsoDirections moveDir) {
        if (moveDir == IsoDirections.N) {
            return owner.y < (float)y - 0.3F;
        } else if (moveDir == IsoDirections.S) {
            return owner.y > (float)(y + 1) + 0.3F;
        } else if (moveDir == IsoDirections.W) {
            return owner.x < (float)x - 0.3F;
        } else if (moveDir == IsoDirections.E) {
            return owner.x > (float)(x + 1) + 0.3F;
        } else {
            throw new IllegalArgumentException("unhandled direction");
        }
    }

    public void setParams(IsoGameCharacter owner, IsoObject obj) {
        HashMap hashMap = owner.getStateMachineParams(this);
        hashMap.clear();
        boolean boolean0 = false;
        boolean boolean1;
        if (obj instanceof IsoWindow isoWindow) {
            boolean1 = isoWindow.north;
            if (owner instanceof IsoPlayer && isoWindow.isDestroyed() && !isoWindow.isGlassRemoved() && Rand.Next(2) == 0) {
                boolean0 = true;
            }
        } else if (obj instanceof IsoThumpable isoThumpable) {
            boolean1 = isoThumpable.north;
            if (owner instanceof IsoPlayer && isoThumpable.getName().equals("Barbed Fence") && Rand.Next(101) > 75) {
                boolean0 = true;
            }
        } else {
            if (!IsoWindowFrame.isWindowFrame(obj)) {
                throw new IllegalArgumentException("expected thumpable, window, or window-frame");
            }

            boolean1 = IsoWindowFrame.isWindowFrame(obj, true);
        }

        int int0 = obj.getSquare().getX();
        int int1 = obj.getSquare().getY();
        int int2 = obj.getSquare().getZ();
        int int3 = int0;
        int int4 = int1;
        int int5 = int0;
        int int6 = int1;
        IsoDirections isoDirections;
        if (boolean1) {
            if ((float)int1 < owner.getY()) {
                int6 = int1 - 1;
                isoDirections = IsoDirections.N;
            } else {
                int4 = int1 - 1;
                isoDirections = IsoDirections.S;
            }
        } else if ((float)int0 < owner.getX()) {
            int5 = int0 - 1;
            isoDirections = IsoDirections.W;
        } else {
            int3 = int0 - 1;
            isoDirections = IsoDirections.E;
        }

        IsoGridSquare isoGridSquare0 = IsoWorld.instance.CurrentCell.getGridSquare(int5, int6, int2);
        boolean boolean2 = isoGridSquare0 != null && isoGridSquare0.Is(IsoFlagType.solidtrans);
        boolean boolean3 = isoGridSquare0 != null && isoGridSquare0.TreatAsSolidFloor();
        boolean boolean4 = isoGridSquare0 != null && owner.canClimbDownSheetRope(isoGridSquare0);
        int int7 = int5;
        int int8 = int6;
        if (boolean2 && owner.isZombie()) {
            IsoGridSquare isoGridSquare1 = isoGridSquare0.getAdjacentSquare(isoDirections);
            if (this.isFreeSquare(isoGridSquare1)
                && !isoGridSquare0.isSomethingTo(isoGridSquare1)
                && isoGridSquare0.getWindowFrameTo(isoGridSquare1) == null
                && isoGridSquare0.getWindowThumpableTo(isoGridSquare1) == null) {
                int7 = isoGridSquare1.x;
                int8 = isoGridSquare1.y;
            } else {
                boolean2 = false;
            }
        }

        if (boolean2 && !owner.isZombie()) {
            IsoGridSquare isoGridSquare2 = this.getFreeSquareAfterObstacles(isoGridSquare0, isoDirections);
            if (isoGridSquare2 == null) {
                boolean2 = false;
            } else {
                int7 = isoGridSquare2.x;
                int8 = isoGridSquare2.y;
            }
        }

        hashMap.put(PARAM_START_X, int3);
        hashMap.put(PARAM_START_Y, int4);
        hashMap.put(PARAM_Z, int2);
        hashMap.put(PARAM_OPPOSITE_X, int5);
        hashMap.put(PARAM_OPPOSITE_Y, int6);
        hashMap.put(PARAM_END_X, int7);
        hashMap.put(PARAM_END_Y, int8);
        hashMap.put(PARAM_DIR, isoDirections);
        hashMap.put(PARAM_ZOMBIE_ON_FLOOR, Boolean.FALSE);
        hashMap.put(PARAM_PREV_STATE, owner.getCurrentState());
        hashMap.put(PARAM_SCRATCH, boolean0 ? Boolean.TRUE : Boolean.FALSE);
        hashMap.put(PARAM_COUNTER, boolean2 ? Boolean.TRUE : Boolean.FALSE);
        hashMap.put(PARAM_SOLID_FLOOR, boolean3 ? Boolean.TRUE : Boolean.FALSE);
        hashMap.put(PARAM_SHEET_ROPE, boolean4 ? Boolean.TRUE : Boolean.FALSE);
    }
}
